<%--
  User: ganesh
  Date: May 30, 2007
  Time: 2:52:55 PM
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/assemblyLotMaxSizeSetup.do" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% try
{%>
<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet"></HEAD>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>

<SCRIPT language="JavaScript">
    var listSize=0;


    function reset()
    {
        document.assemblyMaxLotSizeForm.reset();

    }
    function submitPage()
    {
        var form    = document.assemblyMaxLotSizeForm;
        form.action = "<%=chipTracContext%>/assemblyLotMaxSizeSetup.do?action=loadWaferLotsSize"
        form.submit();
    }
    function save()
    {
        var pa=document.getElementById("errors");
        pa.innerHTML= '';
        var form    = document.assemblyMaxLotSizeForm;
        var selectedLotsObj         = listSize;
        var count1                  = 0;
        /*if( typeof( selectedLotsObj.length ) == "undefined" )
        {

            if( form['fabPartNumbersLotSizeList[0].checked'].checked == true )
            {
                if ( form['fabPartNumbersLotSizeList[0].lotsPerWafer'].value =='-1')
                {
                    pa.innerHTML = "<li> Please select Wfrs Per Lot Size";
                    form['fabPartNumbersLotSizeList[0].lotsPerWafer'].focus();
                    return;
                }
                else
                {
                    count1 = count1+1;
                }
          }
        }
        else*/
        /*{*/
            for( var i=0; i < selectedLotsObj; i++ )
            {
                if( form['fabPartNumbersLotSizeList['+i+'].checked'].checked == true )
                {
                   if ( form['fabPartNumbersLotSizeList['+i+'].lotsPerWafer'].value == '-1')
                   {
                        pa.innerHTML = "<li> Please select Wfrs Per Lot Size";
                        form['fabPartNumbersLotSizeList['+i+'].lotsPerWafer'].focus();
                        return;
                   }
                   else
                   {
                       count1++;
                   }
                }
            }
        /*}*/

        if( count1==0 )
        {
            pa.innerHTML = "<li> Please select atleast one Part Number";
            return;
        }
        form.action = "<%=chipTracContext%>/assemblyLotMaxSizeSetup.do?action=saveWaferLotsSize"
        form.submit();
}
    function calculateMaxSize(index)
    {
        var form    = document.assemblyMaxLotSizeForm;
        if(form['fabPartNumbersLotSizeList['+index+'].checked'].checked == true )
        {
           if(form['fabPartNumbersLotSizeList['+index+'].lotsPerWafer'].value > 0 && form['fabPartNumbersLotSizeList['+index+'].dpw'].value > 0)
           {
               form['fabPartNumbersLotSizeList['+index+'].maxlotSize'].readonly =false;
               form['fabPartNumbersLotSizeList['+index+'].maxlotSize'].value= form['fabPartNumbersLotSizeList['+index+'].lotsPerWafer'].value * form['fabPartNumbersLotSizeList['+index+'].dpw'].value;
               form['fabPartNumbersLotSizeList['+index+'].maxlotSize'].readonly =true;
           }
           else
           {
                form['fabPartNumbersLotSizeList['+index+'].maxlotSize'].value = 0;
           }
        }
        
    }
    function changeMaxSize( index )
    {
        var pa=document.getElementById("errors");
        var form    = document.assemblyMaxLotSizeForm;
        if(form['fabPartNumbersLotSizeList['+index+'].checked'].checked == true )
        {
            form['fabPartNumbersLotSizeList['+index+'].lotsPerWafer'].disabled = false;
        }
        else
        {
            form['fabPartNumbersLotSizeList['+index+'].lotsPerWafer'].disabled = true;
        }

    }


</SCRIPT>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
    <TR>
	    <TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
	    <!-- Side Navigation start -->
	    <%@include file="/jsp/operations/releaseMenu.jsp" %>
	    <!-- end of the side navigations -->
        </TD>
	    <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
	    <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
	    <TD valign="top" width="100%"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
	    <BR>
        <html:form action="/assemblyLotMaxSizeSetup.do" name="assemblyMaxLotSizeForm" type="com.scalar.chiptrack.operations.tapereel.forms.AssemblyMaxLotSixeForm">
            <input type="hidden" name="isSearchSubmit" value="true">
            <TABLE width="80%" align="center" cellpadding="2" cellspacing="2" border="0">
			    <TR><TD colspan="5" class="NArialW" align="center">Assembly Lot Size Setup </TD></TR>
                <TR><TD colspan=6 class='NArialL'><strong><FONT id="message" styleClass="NArialL" color='FF0000'></FONT></strong></TD></TR>
                <TR><TD colspan='5' class="NArialL"><chiptrack:errors styleClass="NArialL"/><chiptrack:info styleClass="NArialL"/></TD></TR>
			    <TR><TD colspan='5' class="NArialL"><FONT id="errors" color='FF0000'></font></TD></TR>
                <TR><TD colspan='5' class="NArialL"><chiptrack:messages type="info" styleClass="NArialL" /></td></tr>
                <tr>
                       <td class="NArialL"> Part Number: </td>
                    <td class="NArialL">
                        <nested:select name="assemblyMaxLotSizeForm" property="processStepId"  styleClass="txfield" >
                            <html:option value="0" >All Part Number</html:option>
                            <logic:present name="partNumbersList">
                                <html:options collection="partNumbersList" property="value" labelProperty="label"/>
                            </logic:present>
                        </nested:select>
                    </td>
                    <td width="5%">&nbsp;</td>
                    <td class="NArialL" width="10%">
                        &nbsp;
                    </td>
                    <td class="NArialL" align="left">
                        &nbsp;
                    </td>
            </tr>
            <TR><TD colspan='5'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
			<tr>
				<td colspan="5" align="center">
                    <a href="javascript:submitPage()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Search Product Reel Quantity ';return true" onmouseout="window.status='';return true" title="Click here to Search Part Number for lot size Max Quantity" alt=""></a>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				    <a href="javascript:reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
				</td>
			</tr>
            <TR><TD colspan='5'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>


            <tr>
                <td colspan="5" >
                    <table width="100%" id="reelQtyTable">
                        <tr bgcolor="#993333">
                            <td align="center" class="NArialL"><font color="#FFFFFF">Select </font></td>
                            <td align="center" class="NArialL"><font color="#FFFFFF">Part Number </font></td>
                            <td align="center" class="NArialL"><font color="#FFFFFF">DPW</font></td>
                            <td align="center" class="NArialL"><font color="#FFFFFF"># Wfrs Per Lot Size</font></td>
                            <td align="center" class="NArialL"><font color="#FFFFFF">Max Lot Size</font></td>
                        </tr>
                    <nested:present property="fabPartNumbersLotSizeList" name= "assemblyMaxLotSizeForm">
                        <nested:size id="listSize" property="fabPartNumbersLotSizeList"/>
                            <script type="text/javascript">
                                listSize=<%=listSize.intValue() %>;
                            </script>
                            <logic:greaterThan value="0" name="listSize" >
                            <nested:iterate id="processStepId" property="fabPartNumbersLotSizeList" indexId="iterateIdx" type="com.scalar.chiptrack.operations.release.AssemblyMaxLotSize">
                            <tr bgcolor=<%=iterateIdx.intValue() % 2 == 0 ? "'#FFFFEE'" : "'#DEE1E2'"%> >
                            <%String click = "changeMaxSize('"+iterateIdx.intValue()+"')";
                             String calculate = "calculateMaxSize('"+iterateIdx.intValue()+"')"; %>
                                <nested:hidden property="processStepId"  />
                                <td align="center" class="NArialL" >
                                    <nested:checkbox property="checked" onclick="<%= click %>"/>
                                </td>
                                <td align="center" class="NArialL" >
                                    <nested:text property="partNumber"  styleClass="txfield" size="15" readonly= "true"/>
                                </td>
                                <td align="center" class="NArialL" >
                                    <nested:text property="dpw"  styleClass="valueTxfield" size="10" readonly="true"/>
                                </td>
                                <td align="center" class="NArialL" >
                                    <nested:select property="lotsPerWafer"  styleClass="txfield" onchange="<%= calculate %>" disabled="true">
                                        <html:option value="-1" >Select</html:option>
                                            <html:option value="1" >1</html:option>
                                            <html:option value="2" >2</html:option>
                                            <html:option value="3" >3</html:option>
                                            <html:option value="4" >4</html:option>
                                            <html:option value="5" >5</html:option>
                                            <html:option value="6" >6</html:option>
                                            <html:option value="7" >7</html:option>
                                            <html:option value="8" >8</html:option>
                                            <html:option value="9" >9</html:option>
                                            <html:option value="10" >10</html:option>
                                            <html:option value="11" >11</html:option>
                                            <html:option value="12" >12</html:option>
                                            <html:option value="13" >13</html:option>
                                            <html:option value="14" >14</html:option>
                                            <html:option value="15" >15</html:option>
                                            <html:option value="16" >16</html:option>
                                            <html:option value="17" >17</html:option>
                                            <html:option value="18" >18</html:option>
                                            <html:option value="19" >19</html:option>
                                            <html:option value="20" >20</html:option>
                                            <html:option value="21" >21</html:option>
                                            <html:option value="22" >22</html:option>
                                            <html:option value="23" >23</html:option>
                                            <html:option value="24" >24</html:option>
                                            <html:option value="25" >25</html:option>
                                    </nested:select>
                                </td>

                                <td align="center" class="NArialL" >
                                    <nested:text property="maxlotSize"  styleClass="valueTxfield" size="10" readonly="true"/>
                                </td>

                        </tr>
                        </nested:iterate>        

            <TR><TD colspan='5'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
            <tr>
                <td colspan="5" align="center">
                    <a href="javascript:save()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Search Product Reel Quantity';return true" onmouseout="window.status='';return true" title="Click here to save Assembly Release Lot Size Max Qty Setup " alt=""></a>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
                </td>
            </tr>

            </logic:greaterThan>
            </nested:present>
                <TR><TD colspan='5'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
                    </table>
                </td>
            </tr>
                    
        </TABLE>
	</html:form>
<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>
<%  }
    catch (Exception q)
    {
        q.printStackTrace();
    }
%>